Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
The boom npm package is a set of utilities for returning HTTP errors. It is part of the hapi ecosystem and provides a way to send error responses that include a friendly error message, the correct HTTP status code, and any additional error information.
Creating HTTP-friendly error objects
Boom allows you to create error objects that are suitable for HTTP responses. For example, you can create a 400 Bad Request error using Boom.badRequest('Invalid request payload input').
{"statusCode": 400, "error": "Bad Request", "message": "Invalid request payload input"}
Decorating error objects
Boom provides a way to decorate error objects with additional information. You can add custom data to an error using Boom.badRequest('Invalid request payload input').data({ custom: 'info' }).
{"statusCode": 400, "error": "Bad Request", "message": "Invalid request payload input", "data": {"custom": "info"}}
Generating errors for various HTTP status codes
Boom has methods for generating errors corresponding to most HTTP status codes, such as Boom.notFound('Resource not found') for a 404 error, or Boom.internal('An internal server error occurred') for a 500 error.
[{"statusCode": 404, "error": "Not Found", "message": "Resource not found"}, {"statusCode": 500, "error": "Internal Server Error", "message": "An internal server error occurred"}]
The http-errors package is similar to boom in that it allows you to create HTTP error objects. It is middleware-friendly and can be used with frameworks like Express. Unlike boom, it does not have a dependency on the hapi ecosystem.
api-error-handler is an Express middleware for handling API errors. It formats error responses in a consistent structure. While it is similar to boom in handling errors, it is specifically designed for Express and is used as middleware rather than a standalone error object generator.
HTTP-friendly error objects
This version of the package requires a commercial license. You may not use, copy, or distribute it without first acquiring a commercial license from Sideway Inc. Using this software without a license is a violation of US and international law. To obtain a license, please contact sales@sideway.com. The open source version of this package can be found here.
FAQs
HTTP-friendly error objects
The npm package boom receives a total of 2,566,235 weekly downloads. As such, boom popularity was classified as popular.
We found that boom demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.